package com.study.singleton.pojo;

/**
 * @ClassName: UnSafeLazySingleton
 * @Description: 懒汉式单例实现类，线程不安全
 * @Details: 注意构造方法设置为private，这样类就不能被实例化
 * @Author: 郑港旭
 * @Create: 2021-11-09 17:11
 **/
public class UnSafeLazySingleton {
    private static UnSafeLazySingleton instance;

    // 让构造函数为private，这样类就不会被实例化
    private UnSafeLazySingleton(){

    }

    public static UnSafeLazySingleton getInstance(){
        if(instance == null){
            instance = new UnSafeLazySingleton();
        }

        return instance;
    }

    public void showMessage(){
        System.out.println("Hello world!");
    }
}
